package game;

import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;

import util.INIGroup;
import GUI.ImageStorage;

public class Tile implements Loadable {
	private BufferedImage img = null;
	private String imgName = "";
	private boolean obstacle = false;
	private int movPenalty = 0;
	private Color mapColor = Color.BLACK;
	private String name = "TILE";
	private String tag = "";
	private String backName = "";
	
	public String getBackName() {
		return backName;
	}

	private int voffset = 0;
	public static final int TILE_SIZE = 64; 
	
	public Tile()
	{
	}

	@Override
	public boolean loadFromFile(INIGroup grupa) {
		imgName = grupa.vals.get("ImageName");
		obstacle = "True".equals(grupa.vals.get("Obstacle"));
		movPenalty = Integer.parseInt(grupa.vals.get("Penalty"));
		int col = Integer.parseInt(grupa.vals.get("Color"), 16);
		mapColor = new Color(col);
		name = grupa.vals.get("Name");
		tag = grupa.vals.get("Tag");
		voffset = grupa.getInteger("OffsetY");
		backName = grupa.getString("BattleBackground", "");
		
		//tileList.add(this);
				
		return true;
	}
	
	public String getTag()
	{
		return tag;
	}

	public BufferedImage getImg() {
		return img;
	}

	public String getImgName() {
		return imgName;
	}

	public boolean isObstacle() {
		return obstacle;
	}

	public int getMovPenalty() {
		return movPenalty;
	}

	public Color getMapColor() {
		return mapColor;
	}

	public String getName() {
		return name;
	}
	
	public int getVOffset()
	{
		return voffset;
	}

	@Override
	public void init() {
		img = ImageStorage.getImage("Tiles" + File.separator + imgName);
		if(img == null) System.out.println("Error loading tile image : " + imgName);
	}
	
}
